import folium

tile_folder = 'tiles/{z}/{x}/{y}.png'

m = folium.Map(
    location=[31.839182, 117.129428],
    zoom_start=15,
    tiles=None,
)

try:
    folium.TileLayer(
        tiles=tile_folder,
        attr='Local Tiles',
        name='Local Tile Map',
        overlay=False
    ).add_to(m)
    print("瓦片图层添加成功")
except Exception as e:
    print(f"添加瓦片图层时出错: {e}")

# 添加点到地图
point_location = [31.839182, 117.129428]
folium.Marker(
    location=point_location,
    popup='这是一个标记点',
    icon=folium.Icon(color='blue', icon='info-sign')
).add_to(m)

folium.LayerControl().add_to(m)

m.save('local_tile_map.html')
    
